using System.Collections.Generic;
using NodeCanvas.Variables;

namespace NodeCanvas.Actions
{
	[Category("✫ Blackboard")]
	[Description("Add a number of GameObjects to the target GameObject list variable")]
	public class SetListGameObjects : ActionTask
	{
		[RequiredField]
		[BlackboardOnly]
		public BBGameObjectList targetList;

		public List<BBGameObject> objectsToAdd = new List<BBGameObject>();

		public bool onlyIfNotContained = true;

		protected override string info
		{
			get
			{
				return "Add " + objectsToAdd.Count.ToString() + " objects to " + targetList;
			}
		}

		protected override void OnExecute()
		{
			foreach (BBGameObject item in objectsToAdd)
			{
				if (!onlyIfNotContained || !targetList.value.Contains(item.value))
				{
					targetList.value.Add(item.value);
				}
			}
			EndAction();
		}
	}
}
